package com.lovo.dept.frame;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JPanel;

import com.lovo.emp.frame.EmpAddDialog;
import com.lovo.emp.frame.EmpPanel;
import com.lovo.emp.frame.EmpShowDialog;
import com.lovo.emp.frame.EmpUpdateDialog;
import com.lovo.netCRM.component.LovoButton;
import com.lovo.netCRM.component.LovoCutPage;
import com.lovo.netCRM.component.LovoTable;
import com.lovo.netCRM.component.LovoTitleLabel;
import com.lovo.netCRM.component.LovoTitlePanel;
import com.lovo.netCRM.component.LovoTxt;

/**
 * 部门管理主面板
 * @author 白德柯
 *
 */
public class DeptPanel extends JPanel{


	/**部门表格组件*/
	private LovoTable deptTable;
	/**窗体组件*/
	private JFrame jf;

	/**分页对象*/
	private LovoCutPage cutPage;

	public DeptPanel(JFrame jf){
		this.jf = jf;
		this.setLayout(null);
		this.init();
	}
	/**
	 * 初始化
	 *
	 */
	private void init() {
		new LovoTitleLabel("部 门 管 理",this);
		this.initTable();
		this.initButton();
		this.initData();
	}
	/**
	 * 初始化数据
	 */
	public void initData(){
		this.updateTable(1);
	}
	
	

	
	//-------------------------------------------------
	/**
	 * 初始化表格
	 *
	 */
	private void initTable() {
		deptTable = new LovoTable(this,
				new String[]{"部门名称","成立时间","部门描述"},
				new String[]{},//部门实体属性名数组 
				"");//主键属性名 
		deptTable.setSizeAndLocation(20, 90, 700, 300);
		// 分页
		cutPage = new LovoCutPage(20,400,this) {
			@Override
			public void clickEvent(int arg0) {
				
			}
		};
	}
	
	/**
	 * 初始化按钮
	 *
	 */
	private void initButton() {
		LovoButton addButton = new LovoButton(50,460,"添加部门","image/add.png",this);
		
		addButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new DeptAddDialog(jf, DeptPanel.this);
			}
		});
		
		LovoButton updateButton = new LovoButton(250,460,"修改部门","image/update.png",this);
		
		updateButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new DeptUpdateDialog(jf, 0, DeptPanel.this);
			}
		});
		

	}
	/**
	 * 更新表格数据
	 */
	private void updateTable(int page){
		//更新表格
		deptTable.updateLovoTable(null);
	}
	




}
